<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加活动</title>
  <link rel="stylesheet" type="text/css" href="<%=path %>/style/easyui.css">
  <link rel="stylesheet" type="text/css" href="<%=path %>/style/icon.css">
  <link rel="stylesheet" type="text/css" href="<%=path %>/style/neweasyui/themes/gray/panel.css">
  <link rel="stylesheet" type="text/css" href="<%=path %>/style/neweasyui/themes/gray/window.css">
  <script type="text/javascript" src="<%=path %>/script/1.11.1.js"></script>
  <script type="text/javascript" src="<%=path %>/script/jquery.easyui.min.js"></script>
  <script type="text/javascript" src="<%=path %>/script/easyui-lang-zh_CN.js"></script>
  <script type="text/javascript" src="<%=path %>/script/dateFormat.js"></script>
  <script type="text/javascript" src="<%=path %>/script/datagrid-bufferview.js"></script>
  <script type="text/javascript" src="<%=path %>/script/common.js"></script>
  <script type="text/javascript" src="<%=path %>/script/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">
#fm {
	margin: 0;
	padding: 10px 30px;
}

.ftitle {
	font-size: 14px;
	font-weight: bold;
	padding: 5px 0;
	margin-bottom: 10px;
	border-bottom: 1px solid #ccc;
}

.fitem {
	margin-bottom: 17px;
}

.fitem label {
	display: inline-block;
	width: 80px;
}

.fitem input {
	width: 230px;
}
</style>
</head>
<body>
	<div id="article-div" style="width:800px;float:left;">
		<div class="easyui-panel" title="编辑文章" style="width:100%;">
			<div style="padding:10px 60px 20px 60px">
				<form id="actForm" action="" method="post">
					<input type="hidden" name="id" value="${activity.id }">
					<div class="fitem">
						<label>活动类型:</label> 
						<select name="activityTypeId">
							<c:forEach items="${typeList }" var="activityType">
								<option value="${activityType.id }"<c:if test="${activityType.id==activity.activityTypeId }">selected</c:if>>${activityType.name}</option>
							</c:forEach>
						</select>
					</div>
					<div class="fitem">
						<label>活动名称:</label> 
						<input name="title" id="title" value="${activity.title }" />
					</div>
					<div class="fitem">
						<label>开始时间:</label>
						<input name="startDate" id="startDate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});" 
							value="<fmt:formatDate value="${activity.startDate }" pattern="yyyy-MM-dd HH:mm"/>"/>

					</div>
					<div class="fitem">
						<label>结束时间:</label>
						<input name="endDate" id="endDate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});" 
							value="<fmt:formatDate value="${activity.endDate }" pattern="yyyy-MM-dd HH:mm"/>"/>
					</div>
					<div class="fitem">
						<label>活动预算:</label>
						<input name="budget" id="budget" value = "${activity.budget }"/>
					</div>
				</form>
				<div style="text-align:center;padding:5px">
					<a href="javascript:void(0)" class="easyui-linkbutton"
						onclick="save()">保存</a>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	
	function check() {
		var title = $("#title").val() ;
		var startDate = $("#startDate").val() ;
		var endDate = $("#endDate").val() ;
		var budget = $("#budget").val() ;
		
		if(title.length==0){
			alert('标题不能为空') ;
			return false ;
		}
		
		if(startDate.length==0){
			alert('开始时间不能为空') ;
			return false ;
		}
		if(endDate.length==0){
			alert('结束时间不能为空') ;
			return false ;
		}
		if(budget.length==0){
			alert('预算不能为空') ;
			return false ;
		}
	}

	function save() {
		$('#actForm').form('submit',{
	         url: '<%=path%>/activityManage/add',
	         onSubmit: function(){
	             return check();
	         },
	         success: function(result){
	        	result = eval('('+result+')');
	            if(result.status=='SUCCESS'){
	        	    alert('操作成功');
       	    		location.href="<%=path%>/pages/activity/activityList.jsp";
	            }else{
	         	   $.messager.alert('提示','操作失败');
	            }
	         }
     	});
	}
</script>
</html>
